<template>
  <Card>
    <iframe id="editIframe"  :src="`${editIframe}iframe-edit.html`" frameborder="0" ref="iframeDom"></iframe>
    <span v-html="codeShow">

    </span>
    <Button @click="executeCode()">执行代码</Button>
  </Card>
</template>

<script>
  import {htmlDecode} from '@/libs/util'
  export default {
    name: 'html-edit',
    data(){
      return{
        editIframe:'/',
        codeShow:'',
        iframeWin: ''
      }
    },
    mounted () {
      this.iframeWin = this.$refs.iframeDom.contentWindow
    },
    methods:{
      executeCode(){
        const editContent = this.iframeWin.document.getElementById('editContent').innerHTML
        let getCode = htmlDecode(editContent)
        console.log(editContent)
        this.codeShow = getCode
      }
    }
  }
</script>

<style scoped>

</style>
